{# **
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * #}

{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% block session_alert %}
  {{ parent() }}

  {# Display generated client secrets passed by session #}
  {% if app.session.flashbag.peek('client_secret')|length() > 0 %}
    {% for clientSecret in app.session.flashbag.get('client_secret') %}
      <div class="alert alert-success d-print-none" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true"><i class="material-icons">close</i></span>
        </button>
        <div class="alert-text">
          {{ 'Client secret:'|trans({}, 'Admin.Advparameters.Feature') }} {{ clientSecret }}
          <a href="#" class="copy-secret-to-clipboard" data-secret="{{ clientSecret|trim }}">
            {{ 'Copy'|trans({}, 'Admin.Actions') }}
            <i class="material-icons">content_copy</i>
          </a>
        </div>
      </div>
    {% endfor %}
  {% endif %}
{% endblock %}

{% block content %}
  {% block api_client_form_block %}
    {{ form_start(apiClientForm) }}

    <div class="card">
      <h3 class="card-header">
        {{ 'API client'|trans({}, 'Admin.Advparameters.Feature') }}
      </h3>

      <div class="card-body">
        <div class="form-wrapper">
          {{ form_widget(apiClientForm) }}
        </div>
      </div>

      <div class="card-footer">
        <a href="{{ path('admin_api_index') }}" class="btn btn-outline-secondary">
          {{ 'Cancel'|trans({}, 'Admin.Actions') }}
        </a>
        <div class="float-right">
          {% block form_submit_buttons %}
            <button type="submit" class="btn btn-primary">
              {{ 'Generate client secret and save'|trans({}, 'Admin.Advparameters.Feature') }}
            </button>
          {% endblock %}
        </div>
      </div>
    </div>

    {{ form_end(apiClientForm) }}
  {% endblock %}
{% endblock %}

{% block javascripts %}
  {{ parent() }}
  <script src="{{ asset('themes/new-theme/public/api_client_form.bundle.js') }}"></script>
{% endblock %}
